package parser.xml;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import modelo.Pagina;

public class EscreverArquivoXML {

	public  static void gravaXMLListaProdutos(Map<String,Pagina> paginas,String localArquivo) {
		XStream xStream = new XStream(new DomDriver());
		xStream.alias("paginas", List.class);
		File arquivo = new File(localArquivo+"/paginas.xml");
		FileOutputStream gravar;

		try {
			gravar = new FileOutputStream(arquivo);
			gravar.write(xStream.toXML(paginas).getBytes());
			gravar.close();
		} 
		catch (IOException ex) {
			System.out.println(ex.getMessage());
		}
	}
}
